package com.gitee.wsl.compose.ui.container

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import com.gitee.wsl.compose.modifier.draw.BackgroundSizing
import com.gitee.wsl.compose.modifier.draw.layer
import com.gitee.wsl.compose.ui.base.Layout
import com.gitee.wsl.compose.ui.theme.LocalContentAlpha


@Composable
fun Layout.Layer(
    modifier: Modifier = Modifier,
    shape: Shape = RoundedCornerShape(size = 4.dp),
    color: Color = MaterialTheme.colorScheme.background,//.colors.background.layer.default,
    contentColor: Color = MaterialTheme.colorScheme.primary,//FluentTheme.colors.text.text.primary,
    border: BorderStroke? = BorderStroke(1.dp, MaterialTheme.colorScheme.outline),//FluentTheme.colors.stroke.card.default),
    backgroundSizing: BackgroundSizing,
    elevation: Dp = 0.dp,
    content: @Composable () -> Unit
) {
    ProvideTextStyle(MaterialTheme.typography.bodyMedium.copy(color = contentColor)) {
        CompositionLocalProvider(
            LocalContentColor provides contentColor,
            LocalContentAlpha provides contentColor.alpha
        ) {
            Box(
                modifier = modifier.layer(
                    elevation,
                    shape,
                    border,
                    backgroundSizing,
                    color
                ),
                propagateMinConstraints = true
            ) {
                content()
            }
        }
    }
}
